package 回溯;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName _78子集
 * @Description TODO
 * @Author 昝亚杰
 * @Date 2021/11/16 20:57
 * Version 1.0
 **/
public class _78子集 {
    List<List<Integer>> results = new ArrayList<>();
    List<Integer> result = new ArrayList<>();
    public List<List<Integer>> subsets(int[] nums) {
        backTrack(nums,0);
        return results;
    }
    private void backTrack(int[] nums, int start){
        results.add(new ArrayList<>(result));//妙啊！！!
        if(start >= nums.length){
            return ;
        }
        for(int i = start; i < nums.length; i++){
            result.add(nums[i]);
            backTrack(nums, i + 1);
            result.remove(result.size() -1);
        }
    }
}
